unit UDmFinanceiro;

interface

uses
  SysUtils, Classes, DB, DBTables;

type
  TDMFinanceiro = class(TDataModule)
    QPlano: TQuery;
    QTipoDocumento: TQuery;
    Qportador: TQuery;
    QEspecie: TQuery;
    QConta: TQuery;
    QCFOP: TQuery;
    QCentro: TQuery;
    QPlanoContabil: TQuery;
    QPlanoEntrada: TQuery;
    QPlanoSaida: TQuery;
    QPlanocentro: TQuery;
    QTipoOperacaoVenda: TQuery;
    QTipoLanctoBancario: TQuery;
    QFonteRecurso: TQuery;
    QChequeOrigem: TQuery;
    QChequeTipoMovto: TQuery;
    QCheque_situcao: TQuery;
    QChequePagto: TQuery;
    QTipoOperacaoVenda_NAO_EXCLUIDOS: TQuery;
    procedure DataModuleCreate(Sender: TObject);
    procedure QFonteRecursoBeforeOpen(DataSet: TDataSet);
    procedure QContaAfterOpen(DataSet: TDataSet);
    procedure QPlanoContabilAfterOpen(DataSet: TDataSet);
    procedure QPlanoSaidaAfterOpen(DataSet: TDataSet);
    procedure QPlanoEntradaAfterOpen(DataSet: TDataSet);
    procedure QPlanoAfterOpen(DataSet: TDataSet);
    procedure QTipoDocumentoAfterOpen(DataSet: TDataSet);
  private
    { Private declarations }

  public
    { Public declarations }
  end;

var
  DMFinanceiro: TDMFinanceiro;

implementation

uses ugestao, UGeral;

{$R *.dfm}

procedure TDMFinanceiro.DataModuleCreate(Sender: TObject);
var
 i :Integer;
begin
 if Codigoempresa = 0 then
  exit;

 QPlanoEntrada.Close;
 QPlanoEntrada.SQL.Clear;
 QPlanoEntrada.SQL.Add('select * from PlanoContas');
 QPlanoEntrada.SQL.Add('Where (CodPai <> 0) And (Natureza like ''E%'') and (tipo like ''A%'') ');
 //QPlanoEntrada.ParamByName('Nat').AsString:= UpperCase(copy(PlanoContasEntrada,1,1))+'%';
 QPlanoEntrada.SQL.Add('Order By Estrutura');

 QPlanoSaida.Close;
 QPlanoSaida.SQL.Clear;
 QPlanoSaida.SQL.Add('select * from PlanoContas');
 QPlanoSaida.SQL.Add('Where (CodPai <> 0) And (Natureza like ''S%'') and (tipo like ''A%'') ');
 //QPlanoSaida.ParamByName('Nat').AsString:= UpperCase(copy(PlanoContasSaida,1,1))+'%';
 QPlanoSaida.SQL.Add('Order By Estrutura');


 for i:= 0 to Self.ComponentCount - 1 do
  begin
   TQuery(Self.Components[i]).Close;
   if (pos(':Emp',TQuery(Self.Components[i]).SQL.Text) <> 0) then
    TQuery(Self.Components[i]).ParamByName('Emp').AsInteger:=Codigoempresa;
   TQuery(Self.Components[i]).Open;
  end;
end;

procedure TDMFinanceiro.QFonteRecursoBeforeOpen(DataSet: TDataSet);
begin
  Qfonterecurso.ParamByName('Emp').AsInteger := Codigoempresa;
end;

procedure TDMFinanceiro.QContaAfterOpen(DataSet: TDataSet);
begin

  DataSet.Last;
  DataSet.First;

end;

procedure TDMFinanceiro.QPlanoContabilAfterOpen(DataSet: TDataSet);
begin

  DataSet.Last;
  DataSet.First;


end;

procedure TDMFinanceiro.QPlanoSaidaAfterOpen(DataSet: TDataSet);
begin

  DataSet.Last;
  DataSet.First;


end;

procedure TDMFinanceiro.QPlanoEntradaAfterOpen(DataSet: TDataSet);
begin

  DataSet.Last;
  DataSet.First;


end;

procedure TDMFinanceiro.QPlanoAfterOpen(DataSet: TDataSet);
begin

  DataSet.Last;
  DataSet.First;


end;

procedure TDMFinanceiro.QTipoDocumentoAfterOpen(DataSet: TDataSet);
begin

  DataSet.Last;
  DataSet.First;


end;

end.
